﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LX.Exceptions;

namespace LX.Core.IO
{
    public class FileHelper
    {
        public static void SaveFile(byte[] data, string filepath)
        {
            if (string.IsNullOrWhiteSpace(filepath))
            {
                throw new BusinessValidException("文件路径不能为空");
            }
            string folderpath = System.IO.Path.GetDirectoryName(filepath);
            if (System.IO.Directory.Exists(folderpath))
            {
                System.IO.Directory.CreateDirectory(folderpath);
            }
            var stream = System.IO.File.Create(filepath);
            stream.Write(data, 0, data.Length);
            stream.Close();
        }
    }
}
